let head = [3, 2, 0, -4]
function ListNode(val) {
    this.val = val;
    this.next = null;
}
let list = new ListNode(head[0])
let num = list
for (let i = 1; i < head.length; i++) {
    num.next = new ListNode(head[i])
    num = num.next
};
// console.log(list);

var hasCycle = function (head) {
    let show = head
    let fast = head
    while (fast && fast.next) {
        show = show.next
        fast = fast.next.next
        if (fast === show) {
            return true
        }
    }
    return false
};
console.log(hasCycle(list));
